﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
using System.Web.Services;
using DL;
using System.Runtime.Serialization.Json;

/// <summary>
/// Summary description for WebService
/// </summary>
[ScriptService]
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{

    public WebService()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld()
    {
        return "Hello World";
    }

    [WebMethod]
    public void AddFav(string carID)
    {
        DL.CarService dbconnector = new DL.CarService();
        int id = Convert.ToInt32(carID);
        dbconnector.ChangeFav(id);
    }
    [WebMethod]
    public List<Tuple<int,string>> Getmodels(string manufacturerID)
    {
        DL.CarService dbconnector = new DL.CarService();
        int id = Convert.ToInt32(manufacturerID);
        var data = dbconnector.GEtModelByManufacturer(id)
            .Select(row => new Tuple<int, string>(row.ModelID, row.Name)).ToList();
       return data;
    }
}
